package main

import (
	"crypto/md5"
	"crypto/sha1"
	"fmt"
	"io"
	"os"
)

func main() {
	test := "hi,wyx!"
	MD5Instance := md5.New()
	MD5Instance.Write([]byte(test))

	result := MD5Instance.Sum([]byte(""))
	fmt.Printf("MD5: %x\n\n", result)

	sha1Int := sha1.New()
	sha1Int.Write([]byte(test))

	_result := sha1Int.Sum([]byte(""))
	fmt.Printf("SHA1: %x\n\n", _result)

	file, err := os.Open("D:/gofile/uploads/10.txt")
	if err == nil {
		MD5Instance := md5.New()
		io.Copy(MD5Instance, file)
		fmt.Printf("%x  %s\n", MD5Instance.Sum([]byte("")), file)

		sha1Instance := sha1.New()
		io.Copy(sha1Int, file)
		fmt.Printf("%x  %s\n", sha1Instance.Sum([]byte("")), file)
	} else {
		fmt.Println(err)
		os.Exit(1)
	}

}
